//
//  VideoBrowserFlowLayout.swift
//  MyVideo
//
//  Created by han on 2021/4/20.
//

import UIKit

class VideoBrowserFlowLayout: UICollectionViewFlowLayout {
    static let padding: CGFloat = 16
    
    override func prepare() {
        if let collectionView = collectionView {
            let minInset = VideoBrowserFlowLayout.padding
            minimumInteritemSpacing = minInset
            minimumLineSpacing = minInset
            sectionInset = UIEdgeInsets(top: minInset, left: minInset, bottom: minInset, right: minInset)
            let width = collectionView.safeAreaLayoutGuide.layoutFrame.width - (minInset * 2)
            let maxHeight = min(304, width)
            itemSize = CGSize(width: width, height: maxHeight)
        }
        super.prepare()
        // 需要将 estimatedItemSize设置为none
    }
}
